package org.example.types.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

/**
 * 插件搜索结果
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PluginSearchResult implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 搜索结果列表
     */
    private List<SearchResult> results;

    /**
     * 是否为最终结果
     */
    private boolean isFinal;

    /**
     * 结果时间戳
     */
    private LocalDateTime timestamp;

    /**
     * 插件来源
     */
    private String source;

    /**
     * 消息
     */
    private String message;

    /**
     * 创建空结果
     */
    public static PluginSearchResult empty(String source) {
        return PluginSearchResult.builder()
                .results(Collections.emptyList())
                .isFinal(false)
                .timestamp(LocalDateTime.now())
                .source(source)
                .message("处理中，后台继续...")
                .build();
    }

    /**
     * 创建成功结果
     */
    public static PluginSearchResult success(String source, List<SearchResult> results) {
        return PluginSearchResult.builder()
                .results(results)
                .isFinal(true)
                .timestamp(LocalDateTime.now())
                .source(source)
                .message("搜索完成")
                .build();
    }
}